<template>
    <div>
        <p> 您的订单已经生成 {{ orderdata.product_code }}</p>
    <p> 用户名为 {{ orderdata.username }}</p>
    <p> 总结为 {{ orderdata.totalPrice / 100 }}</p>
    </div>
      <van-submit-bar :price="orderdata.totalPrice" button-text="提交订单" @submit="onSubmit" />

</template>

<script setup>
import { useRoute } from "vue-router";
let route = new useRoute();

import { OrderDetailApi } from "@/api/api";
import { ref } from "vue";

import { useCounterStore } from "@/stores/cart";
const store = useCounterStore();

let orderdata = ref([]);

OrderDetailApi(route.params.orderId).then((res) => {
  console.log("订单数据", res);
  orderdata.value = res.data.data;
  paydata.value = {
    orderId: res.data.data.orderId,
    subject: res.data.data.product_code,
    totalPrice: res.data.data.totalPrice / 100
  }
});

import { payApi } from "@/api/api";
let paydata = ref({
  orderId: '',
  subject: '',
  totalPrice: 0
})

const onSubmit = () => {
  console.log(paydata.value);
  payApi(paydata.value).then(res => {
    window.open(res.data.data, '_blank')
  })
}
</script>

<style lang="scss" scoped>

</style>